#include "SystemInfo.h"
#include <string>
#include <fstream>
#include <iomanip>

namespace MC500
{

    std::string ConvertSize(uint64_t size, uint8_t unit)
    {
        if (size < 1024)
        {
            std::ostringstream stream;
            stream << setw(4) << setfill(' ') << right << size;
            stream << setw(1);
            switch (unit)
            {
            case 0:
                stream << 'B';
                break;
            case 1:
                stream << 'K';
                break;
            case 2:
                stream << 'M';
                break;
            case 3:
                stream << 'G';
                break;
            case 4:
                stream << 'T';
                break;
            default:
                stream << '?';
            }
            return stream.str();
        }
        return ConvertSize(size >> 10, ++unit);
    }

    SystemInfo *SystemInfo::_ins = nullptr;

    SystemInfo *SystemInfo::GetInstance()
    {
        if (_ins == nullptr)
        {
            _ins = new SystemInfo();
        }
        return _ins;
    }

} // namespace MC500